home *** CD-ROM | disk | FTP | other *** search
-
- ---------------------------------------------------------------------
- An introduction to using Idm.library in you applications.
- ---------------------------------------------------------------------
-
- Idm.library is a standard Amiga run-time library that enables the
- programmer to quickly identify files. Idm.library may be used with any
- programming language that can handle calls to Amiga run time libraries.
-
- To correctly identify files the following step of events must occur:
-
- 1. Open the library using exec.library/OpenLibrary()
-
- 2. Call the Idm.library/IdmAllocIdInfo() function with the desired tags.
- This function (if successful) will return a pointer to an IdInfo
- structure. This pointer *MUST* later be released with the function
- Idm.library/IdmFreeIdInfo().
-
- 3. Call the Idm.library/IdmObtainIOLen() function. This function MUST
- be called if you don't want to load the whole file to memory, but
- instead want to load the smallest amount of bytes possible. Loading
- the smallest amount of bytes is normally the prefered method when
- scanning many files (eg: whole directories).
-
- 4. Load the file to memory (remember to allocate some memory before
- doing this :) - If you require the whole file to be in memory then
- simply load it, but if you don't need the whole file in memory, then
- load the amount specified by Idm.library/IdmObtainIOLen() off the
- *START* of the file. Remember to Seek() to the start of the file.
-
- 5. Identify the file. By passing the IdInfo structure you got earlier
- from Idm.library/IdmAllocIdInfo() + a pointer to the file + the
- amount of bytes that have been loaded off the file + a taglist
- to the Idm.library/IdmIdentifyMem() function, you will get a string
- pointer or NULL. If you get a NULL then this means that Idm.library
- was unable to identify the file, else if you get a non-NULL then
- this will point to a descriptive NULL-terminated identification string.
-
- You can also examine the IdInfo structure to get more information
- on errors, etc.
-
- 6. Do your stuff. Report the filetype to the user of your program, etc.
-
- 7. Free your file, again this is up to you.
-
- 8. Free the IdInfo structure that you got from the Idm.library/
- IdmAllocIdInfo() function.
-
- 9. Close Idm.library.
-
- These are the minimum steps required to identify a file. You might
- also want to obtain more information on the currently installed version
- of Idm.library. To do this Idm.library provides the following support
- functions fow this purpose:
-
- IdmObtainLibInfo() - Get some general information on Idm.library.
- IdmFreeLibInfo() - Free the structure returned by IdmObtainLibInfo().
-
- The function IdmObtainLibInfo() will return pointer to the following
- structure (example in C) else NULL on a failure:
-
- struct IdmLibInfo
- {
- ULONG IdmLI_MagicId;
- UWORD IdmLI_Version;
- UWORD IdmLI_Revision;
- ULONG IdmLI_AmtKnown;
- struct IdmKnownList *IdmLI_IDList;
- ULONG IdmLI_IOLen;
- UWORD IdmLI_Reserved01;
- UWORD IdmLI_Reserved02;
- APTR IdmLI_MaxName;
- UBYTE *IdmLI_DateStr;
- ULONG IdmLI_AmtCat;
- };
-
- Remember to pass this structure to IdmFreeLibInfo() when you are
- finished with it. Here is what each field means:
-
- IdmLI_Version
- IdmLI_Revision
-
- The version and revision of the currently installed version of Idm.library.
-
- IdmLI_AmtKnown
-
- The amount of file types known to this version of Idm.library.
-
- IdmLI_IDList
-
- A pointer to a stand Amiga linked list header. This list will contain
- all the filetype names known to current version Idm.library. Each node
- in this list will be extended with the following structure.
-
- struct IdmKnownNode
- {
- struct Node IdmKN_NodeHead;
- UWORD IdmKN_Pad01;
- ULONG IdmKN_Magic;
- UWORD IdmKN_Flags;
- UWORD IdmKN_Catagory;
- UWORD IdmKN_InternId;
- UWORD IdmKN_Pad02;
- ULONG IdmKN_IOLen;
- };
-
- All of the fields in this node are private. Work is still in progress
- on this structure. Accessing these fields might break your program.
-
- However, you may access the ln_Name (LN_NAME in assembly) field in the
- node at the start of the structure. This will contain the name of
- current idetification string.
-
- This list is designed for attaching to a gadtools.library listview
- gadget or similar.
-
- IdmLI_IOLen
-
- The minimun IOLen required by this version of Idm.library. This value is the
- same as the result returned by the Idm.library/IdmObtainIOLen() function.
-
- IdmLI_MaxName
-
- Identification string of filetype that requires the most amount of bytes to
- be loaded off the start of a file to ensure a proper identification check.
-
- In other words, just ignore it, Its is normally used for debugging, etc.
-
- IdmLI_DateStr
-
- A pointer to a date string. This date indicates the compile date of
- the current version of Idm.library. It looks like DD-MMM-YY.
-
- IdmLI_MagicId
- IdmLI_Reserved01
- IdmLI_Reserved02
-
- Ignore these, they are used internally. Accessing these will break
- your program! You have been warned.
-
- IdmLI_AmtCat
-
- Don't access this, its a work-in-progress thing for a future version of
- Idm.library. Accessing this might break your program.
-
- ---------------------------------------------------------------------
- This file is copyright © 1999 Andrew Bell, created on Mon/22/Feb/1999
-